package n3252;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	static long Cab(int n,int m)
	{
		if(m > n - m) m = n - m;
	    long ans = 1, cou = m;
	    while(cou-->0){
	        ans *= n --;
	        while(ans % m == 0 && m > 1)
	            ans /= m --;
	    }
	    return ans;
	}
	
	static int solve(int n)
	{
		if(n<=1)return 0;
		int cnt=0;
		int h1=(int)(Math.log(n)/Math.log(2));
		int a=0;
		for(int i=h1;i>=1;i--)
		{
			if((i%2)==1){
				cnt+=((Math.pow(2, i-1)-Cab(i-1,(i-1)/2))/2);
			}else{
				cnt+=(Math.pow(2, i-1)/2);
			}
		}
		for(int i=0;i<=h1;i++)
		{
			if((n&(1<<i))!=0){
				a--;
			}else{
				a++;
			}
		}
		if(a>=0)cnt++;//当前数为round number
		
		int n1=1,n0=0;
		for(int i=h1-1;i>=0;i--)
		{
			if((n&(1<<i))!=0)
			{
				for(int j=i;j>=0&&j+n0+1>=i-j+n1;j--)
				{
					cnt+=Cab(i,j);
				}
				n1++;
			}else{
				n0++;
			}
		}
		return cnt;
	}
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {

		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(bf.readLine());
		int n1=Integer.parseInt(st.nextToken());
		int n2=Integer.parseInt(st.nextToken());
		System.out.println(solve(n2)-solve(n1-1));
	}

}
